package org.sl.flvplayer.helper {

	/**
	 * Converts seconds in hours, minutes and seconds.
	 * 
	 * @package org.sl.flvplayer.helper
	 * @author Dan
	 * @version 
	 * @see org.sl.flvplayer.elements.SeekControllerElement
	 */ 
	public class TimeCode {

		private var _showHours : Boolean = false;

		/**
		 * Defines whether hours are shown or not.
		 * 
		 *@param show boolean value 
		 */			
		public function showHours(show : Boolean):void {
			_showHours = show;
		}

		/**
		 * Calculates the time and ads a leading zero to the result returning it as a String.
		 * 
		 *@param seconds seconds
		 *@return returns a <code>String</code> composed of hours, minutes and seconds 
		 */	
		public function getTC(seconds : Number) : String {			
			var result : String = "";		
			var myTime : * = new Date(2009, 0, 1, 0, 0, seconds);			
			// hours
			if (_showHours == true) {
				if (myTime.getHours() < 10) {
					result = "0" + myTime.getHours() + ":";
				} else {
					result = myTime.getHours() + ":";
				}
			}		
			// minutes
			if (myTime.getMinutes() < 10) {
				result += "0" + myTime.getMinutes() + ":";
			} else {
				result += myTime.getMinutes() + ":";
			}					
			// seconds
			if (myTime.getSeconds() < 10) {
				result += "0" + myTime.getSeconds();
			} else {
				result += myTime.getSeconds();
			}						
			return result;
		}
	}
}